package com.avery.imp;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.avery.dao.IGroupContentDao;
import com.avery.entity.Groupcontent;
import com.avery.util.DBUtils;

public class GroupContentDaoImp implements IGroupContentDao {

	public void insert(Groupcontent groupContent) {
		SqlSession locSession = DBUtils.getSqlSessionFactory().openSession();
		locSession.insert("GroupContent.insert", groupContent);
		locSession.commit();
	}

	public void deleteByID(int groupContentID) {
		SqlSession locSession = DBUtils.getSqlSessionFactory().openSession();
		locSession.delete("GroupContent.delete", groupContentID);
		locSession.commit();
	}

	public List<Groupcontent> getAllGroupContentHasTargetUser(int uid) {
		SqlSession locSession = DBUtils.getSqlSessionFactory().openSession();
		List<Groupcontent> groupContents = locSession.selectList("GroupContent.getByUserId", uid);
		locSession.commit();
		return groupContents;
	}

}
